package sample.algo.sistr.algosample;

import android.os.Bundle;
import android.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import sample.algo.sistr.algosample.algos.Algo;
import sample.algo.sistr.algosample.algos.Algos;

/**
 * A fragment representing a single Algo detail screen.
 * This fragment is either contained in a {@link algoListActivity}
 * in two-pane mode (on tablets) or a {@link algoDetailActivity}
 * on handsets.
 */
public class algoDetailFragment extends Fragment {
    /**
     * The fragment argument representing the item ID that this fragment
     * represents.
     */
    public static final String ARG_ITEM_ID = "item_id";

    /**
     * The algo this fragment is presenting.
     */
    private Algo algo;

    /**
     * Mandatory empty constructor for the fragment manager to instantiate the
     * fragment (e.g. upon screen orientation changes).
     */
    public algoDetailFragment() {
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        if (getArguments().containsKey(ARG_ITEM_ID)) {
            int algo_pos = getArguments().getInt(ARG_ITEM_ID);
            algo = Algos.ALGOS.get(algo_pos);
        }
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        ViewGroup rootView = (ViewGroup)inflater.inflate(R.layout.fragment_algo_detail, container, false);

        if (algo != null) {
            rootView.addView(algo.GetDisplay());
        }

        return rootView;
    }
}
